// 主界面

#include "head.h"

class UIMain : public UI::Scene
{
public:
	UIMain()
	{
		{
			gcSprite spr = g_factory->CreateSpriteDefault();
			spr->SetColor(createColor(0x0f0f0fff), 0);
			spr->SetColor(createColor(0x000000ff), 1);
			spr->SetColor(createColor(0x0f0f0fff), 2);
			spr->SetColor(createColor(0x2f2f2fff), 3);
			UI::Sprite* ui_spr = UI::Sprite::Create(
				spr, UI::Sprite::AutoSize::PANEL, UI::Sprite::FillMode::STRETCH);
			GetPanelRoot()->SetOrderMode(UI::Panel::FORCE);
			GetPanelRoot()->SetOrder(0.9f);
			GetPanelRoot()->Add(ui_spr);
		}
		_panelMenu = CreatePanel("menu");
		{
			UI::Background* bg = UI::Background::Create();
			bg->Set(Sprite9::Create("ui.bg_quad_outline"));

			UI::Panel* panel_menu = g_ui->CreatePanel();
			UI::ButtonSprite* btn_menu = UI::ButtonSprite::Create(
				g_factory->CreateSpriteMulti("ui.btn_menu"));
			btn_menu->SetMode(UI::ButtonMode::RADIO);
			btn_menu->AddText(g_factory->CreateText(0, 18),
				{ ColorDef::BLACK }, {});
			
			panel_menu->Add(btn_menu);

			UI::Background* bg_combo = UI::Background::Create();
			bg_combo->Set(Sprite9::Create("ui.bg_outline"));

			UI::Menu* menu = UI::Menu::Create(
				bg, panel_menu, createLocatorX(100),
				bg_combo, panel_menu->Clone(), createLocatorY(32));
			menu->SetMenuBackgroundOffset({ -0,-0 });
			menu->SetMenuBackgroundSize({ 1920, 48 });
			UI::MenuData data;
			{
				UI::MenuTop& top = data.AddTop();
				top.SetString("文件");
				UI::MenuGroup& g0 = top.AddGroup();
				UI::MenuNode& n0 = g0.AddNode();
				n0.SetString("新建工程");
				UI::MenuNode& n1 = g0.AddNode();
				n1.SetString("打开工程");
			}
			{
				UI::MenuTop& top = data.AddTop();
				top.SetString("编辑");
				UI::MenuGroup& g0 = top.AddGroup();
				/*UI::MenuNode& n0 = g0.AddNode();
				n0.SetString("新建工程");*/
			}
			menu->Refresh(data);
			_panelMenu->Add(menu);
		}
	}
private:
	UI::Panel* _panelMenu;


};